package com.bidevalution.controller.api;

import com.bidevalution.business.service.BeRemoteExpertLoginService;
import com.bidevalution.dao.entity.BeMethodStep;
import com.bidevalution.dao.entity.BeSectionEvalutionResult;
import com.bidevalution.support.context.Constants;
import com.bidevalution.support.exception.BizException;
import com.qtp.common.core.ContextHolderUtils;
import com.qtp.core.model.Paging;
import com.qtp.core.model.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 远程评标系统专家登录验证控制层
 * Created by glodon on 2019-12-27.
 */
@Log4j2
@RestController
@RequestMapping("/beRemoteExpertLogin")
@Api(tags = "远程评标系统专家登录验证")
public class BeRemoteExpertLoginController {

    @Autowired
    private BeRemoteExpertLoginService beRemoteExpertLoginService;
    /**
     * 专家校验接口
     * @param loginId 单点登录时的loginid
     * @return
     */
    @ApiOperation(value = "专家校验接口", notes = "专家校验接口", response = Response.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginid", value = "单点登录时的loginid", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/getExpertToken")
    public Response getExpertToken(@RequestParam("loginid")String loginId) {
        if (StringUtils.isBlank(loginId)) {
            return Response.fail("参数不可以为空", Constants.FIVE_HUNDRED_AND_ONE);
        }
        try {
            return Response.ok(beRemoteExpertLoginService.getExpertToken(loginId));
        } catch (BizException e) {
            log.error(e.getMessage(), e);
            return Response.fail(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Response.fail("获取专家验证信息失败！");
        }
    }
}
